﻿package net.wangit.dev.wizard;

import net.wangit.MapList;
import net.wangit.Unit;
import net.wangit.context.ActionContext;
import net.wangit.context.ActionContextHelper;
import net.wangit.framework.session.AgileSession;
import net.wangit.framework.session.UnitSettings;
import net.wangit.support.UnitInterceptor;
import net.wangit.view.unit.UnitComponent;

public class CaseListUI implements UnitInterceptor {

	private static final MapList DATA_DEMO;

	public CaseListUI() {
	}

	public String intercept(ActionContext ac, Unit unit) throws Exception {
		unit.setData(DATA_DEMO);
		AgileSession fus = ActionContextHelper.getSession(ac);
		UnitSettings us = fus.getUnitSettings(((UnitComponent) unit)
				.getDomain(), unit.getId());
		us.setPageNumber(1);
		us.setMaxSize(2);
		return unit.write(ac);
	}

	static {
		DATA_DEMO = new MapList();
		DATA_DEMO.put(0, "a", "a1");
		DATA_DEMO.put(0, "b", "b1");
		DATA_DEMO.put(0, "c", "c1");
		DATA_DEMO.put(0, "d", "d1");
		DATA_DEMO.put(1, "a", "a2");
		DATA_DEMO.put(1, "b", "b2");
		DATA_DEMO.put(1, "c", "c2");
		DATA_DEMO.put(1, "d", "d2");
	}
}
